﻿using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;

namespace SerialManager
{
    internal static class XElementExtensions
    {
        public static String GetAttributeValueOrEmpty(this XElement element, XName name)
        {
            if (element != null)
            {
                var attribute = element.Attribute(name);

                if (attribute != null)
                {
                    return attribute.Value;
                }
            }

            return String.Empty;
        }
    }
    
    internal static class FileInfoExtensions
    {
        public static Boolean HasAnyExtension(this FileInfo f, params String[] extensions)
        {
            return extensions.Any(ext => f.Extension == ('.' + ext));
        }
    }
}
